﻿using System;
using System.Linq;

namespace Longbow.Web
{
    /// <summary>
    ///
    /// </summary>
    internal class BaiDuIPLocator : DefaultIPLocator
    {
        /// <summary>
        /// 详细地址信息
        /// </summary>
        public string Address { get; set; }

        /// <summary>
        /// 结果状态返回码
        /// </summary>
        public int Status { get; set; }

        /// <summary>
        ///
        /// </summary>
        /// <param name="option"></param>
        /// <returns></returns>
        public override string Locate(IPLocatorOption option) => Locate<BaiDuIPLocator>(option);

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return Status == 0 ? string.Join(" ", Address.SpanSplit("|").Skip(1).Take(2)) : "XX XX";
        }
    }
}
